use std::io::{self, Write};

use dalton_lib::parse;

fn main() {
    loop {
        print!("> ");
        let _ = io::stdout().flush();
        let mut input = String::new();
        io::stdin().read_line(&mut input).expect("cannot read");
        let input = input.trim();
        match input {
            "exit" | ":exit" | "quit" | ":quit" | "exit()" | "quit()" | "q" | "e" => {
                break;
            }
            _ => match parse(input) {
                Ok(res) => {
                    println!("{}", res)
                }
                Err(e) => {
                    eprintln!("Error: {}", e)
                }
            },
        }
    }
}
